from .parse_anime import ParseAnime
from .parse_manga import CheckAniMa
from .notify import Notify


class TrackData():
    def run(self, data, led):
        """ Getting data of tracking. """
        self.anime = ParseAnime()
        self.manga = CheckAniMa(led)
        self.notify = Notify()

        try:
            name, link, data, anime = self.anime.checkRelease(data, led, 0)
            data, manga = self.manga.run(data)
            ranobe = False

            mode = 6 if anime and manga and ranobe else 3 if anime and manga \
                    else 4 if anime and ranobe else 5 if manga and \
                    ranobe else 0 if anime else 1 if manga else 2
            count = anime + manga + ranobe

            data['anime']['track-name'] = name
            data['anime']['track-link'] = link

            track = (data, (count, mode))
        except Exception as e:
            count, mode = None, None

        return data, (count, mode)
